package com.iccct.feign.common;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * comment
 *
 * @author iccct (taowutt1@gmail.com)
 * @since 2021-07-26  17:01
 */
@AllArgsConstructor
@NoArgsConstructor
@Getter
public enum OKResponse {

    QUERY(200, "查询成功"),
    IMPORT(200, "导入成功"),
    INSERT(200, "插入成功"),
    UPDATE(200, "更新成功"),
    LOGIN(200, "登录成功"),
    REGIST(200, "注册成功"),
    LOGOUT(200, "退出成功"),
    DELETE(200, "删除成功"),
    UPLOAD_FILE(200, "文件上传成功"),
    INSERT_NOT_EXIST(200, "前端唯一标示不存在"),
    ;
    private Integer code;
    private String msg;


    public <T> Response<T> toResponse(T data) {
        if (data == null) {
            return new Response<T>(this.code, this.msg, null);
        }
        return new Response<T>(this.code, this.msg, data);
    }

    public Response toResponse() {
        return new Response<>(this.code, this.msg);
    }


}
